/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package codegener.comp;

import codegener.entity.DsBean;
import codegener.entity.GenerBean;
import codegener.tool.DBGet;
import codegener.tool.Gener;
import java.awt.BorderLayout;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author 32181
 */
public class SetupDialog extends javax.swing.JDialog {

   private MFrame mframe;
    
    /**
     * Creates new form SetupDialog
     */
    public SetupDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        mframe=(MFrame)parent;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        rootTabPane = new javax.swing.JTabbedPane();
        generForm1 = new codegener.comp.GenerForm();
        tempForm2 = new codegener.comp.TempForm();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("设置");
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });

        rootTabPane.addTab("生成配置", generForm1);
        rootTabPane.addTab("模板配置", tempForm2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(rootTabPane, javax.swing.GroupLayout.DEFAULT_SIZE, 849, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(rootTabPane)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        // TODO add your handling code here:
//        DsBean ds=dsForm1.getNowDsBean();
//        if(null!=ds&&ds.isValid()){
//            DBGet.initDs(ds.getType(), ds.getUrl(), ds.getUname(), ds.getUpass());    
//        }else{
//            
//        }
        tempForm2.saveFTL();
        mframe.flush();
                
        Gener.flushTemplate(Gener.getTemps());
    }//GEN-LAST:event_formWindowClosed

    public GenerBean getGenerBean(){
        return generForm1.getGenerBean();
    }
    
    public void initDsAndTemp(){
        try{
//            DsBean ds=dsForm1.getNowDsBean();
//            if(null!=ds&&ds.isValid()){
//                DBGet.initDs(ds.getType(), ds.getUrl(), ds.getUname(), ds.getUpass());    
//            }
            Gener.flushTemplate(Gener.getTemps());
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private codegener.comp.GenerForm generForm1;
    private javax.swing.JTabbedPane rootTabPane;
    private codegener.comp.TempForm tempForm2;
    // End of variables declaration//GEN-END:variables
}
